package com.pearl.generator.common;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @author TangDan
 * @version 1.0
 * @since 2022/8/5
 */
@Data
@ApiModel(value = "PageResult对象", description = "统一分页结果集")
public class PageResult<T> extends Result<T> {

    @ApiModelProperty(value = "分页总条数")
    private Long total;

    public static <T> PageResult<T> success(T dataList, Long total) {
        PageResult<T> result = new PageResult<>();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(dataList);
        result.setTotal(total);
        return result;
    }
}
